define(
[],
function(){
    return {
        create: function() {
            //Publics
            function addSystem(system) {
                //Check slot availability
                if(_systems[system.getClass().getName()])
                    throw "SystemManager.js - addSystem() - Slot occupied!"

                //Add system
                _systems[system.getClass().getName()] = system;
                system.getSystemManager = F_getSystemManager;
            }

            function remSystem(system) {
                system.getSystemManager = null;
                _systems.splice(_system.indexOf(system), 1);
            }

            function getSystem(systemClass) {
                return _systems[systemClass.getName()];
            }

            function initializeAll() {
                for(var idx in _systems) {
                    _systems[idx].init();
                }
            }

            function destroy() {
                _systems.forEach(function(val){
                    val.destroy();
                });
                _systems = null;
            }


            //Privates
            var F_getSystemManager = function() { return _self; };
            var _systems = [];

            //
            var _self = {
                addSystem: addSystem,
                remSystem: remSystem,
                getSystem: getSystem,
                initializeAll: initializeAll,
                destroy: destroy,
            };

            return _self;
        }
    };
}
);